/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.presenter;

import android.util.Log;

//import androidx.annotation.NonNull;

import com.xuexiang.templateproject.http.ApiService;
//import com.xuexiang.templateproject.http.RetrofitManager;
import com.xuexiang.templateproject.utils.ViewLifecycle;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
//import kotlin.Lazy;
//import kotlin.LazyKt__LazyJVMKt;
//import kotlin.LazyKt;
//import kotlin.LazyThreadSafetyMode;
//import kotlin.Metadata;
//import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
//import kotlin.jvm.internal.Lambda;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class BasePresenter<T extends IBaseView> extends ViewLifecycle implements IPresenter<T> {
    @Nullable

    /* renamed from: b  reason: collision with root package name */
    public T mRootView;

    @NotNull

    /* renamed from: c  reason: collision with root package name */
    public CompositeDisposable mCompositeDisposable = new CompositeDisposable();

    public static final class MvpViewNotAttachedException extends RuntimeException {
        public MvpViewNotAttachedException() {
            super("Please call IPresenter.attachView(IBaseView) before requesting data to the IPresenter");
        }
    }

    public final void addSubscription(@NotNull Disposable disposable) {
        Intrinsics.checkNotNullParameter(disposable, "disposable");
        this.mCompositeDisposable.add(disposable);
    }

    @Override // com.jcds.common.base.IPresenter
    public void attachView(@NotNull T mRootView) {
        Intrinsics.checkNotNullParameter(mRootView, "mRootView");
        this.mRootView = mRootView;
    }

    public final void checkViewAttached() {
        Log.e("TAG", String.valueOf(isViewAttached()));
        if (!isViewAttached()) {
            throw new MvpViewNotAttachedException();
        }
    }

    @Nullable
    public final T getMRootView() {
        return this.mRootView;
    }

    ApiService  mApiService = null;
    @NotNull
    public final ApiService getService() {
//        if(mApiService==null){
//            mApiService =  (ApiService) RetrofitManager.INSTANCE.getRetrofit("https://app.jiucuodashi.com").create(ApiService.class);
//        }

        return mApiService;
    }

    @Override // com.jcds.common.base.IPresenter
    public void detachView() {
        this.mRootView = null;
        if (!this.mCompositeDisposable.isDisposed()) {
            this.mCompositeDisposable.clear();
        }
    }

    public final boolean isViewAttached() {
        return this.mRootView != null;
    }

}